package io.gitee.hchaojie.day01.exam;

import org.junit.Test;

public class Exam2 {
    /**
     * 每月天数计算
     */
    @Test
    public void testMonthDays() {
        int year = 1900;
        int month = 12;

        int days = 0;

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                days = 31;
                break;

            case 2:
                boolean isLeapYear = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
                days = isLeapYear ? 29 : 28;
                break;

            case 4:
            case 6:
            case 9:
            case 11:
                days = 30;
                break;

            default:
                System.out.println("非法的月份");
                break;
        }

        System.out.println(days);
    }

}
